﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JohnnySins.Entities
{
    public class Archive
    {
        public DateTime FileDate { get; set; }
        public string FilePath { get; set; }
        public string FileName 
        { 
            get 
            {
                if (string.IsNullOrEmpty(FilePath))
                    return "";

                return Path.GetFileName(FilePath);
            } 
        }
        public int FileIndex { get; set; }
        public string ArchiveType { get; set; }
        public string Description 
        {
            get
            {
                if (FileName.Substring(0, 1) != "_")
                    return FileDate.ToString("yyyy-MM-dd") + " - " + ArchiveType + " - " + FileIndex.ToString();
                else
                {
                    string result = Path.GetFileNameWithoutExtension(FilePath);
                    result = result.Substring(1, result.Length - 1);
                    int i = result.IndexOf('_');
                    if (i >= 0)
                    {
                        result = result.Substring(i + 1, result.Length - i - 1);
                    }

                    return result;
                }
            }
        }
    }
}
